package org.lq.ssm.dto.mapper;

import org.lq.ssm.dto.RoleDTO;
import org.lq.ssm.po.DeptPO;
import org.lq.ssm.po.MenuPO;
import org.lq.ssm.po.PermissionPO;
import org.lq.ssm.po.RolePO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface RoleDTOMapper {
    //先写前面的INSTANCE，后面的getMapper才不报错
    RoleDTOMapper INSTANCE = Mappers.getMapper(RoleDTOMapper.class);

    @Mappings({
            @Mapping(source = "deptPOS" ,target = "depts" ),
            @Mapping(source = "menuPOS", target = "menus"),
            @Mapping(source = "permissionPOS",target = "permissions")
    })
    RoleDTO RolePOToRoleDTO(RolePO rolePO, List<DeptPO> deptPOS, List<PermissionPO> permissionPOS, List<MenuPO> menuPOS);
    List<RoleDTO> RolePOSTORoleDTOS(List<RolePO> rolePOS);

    @Mappings({
            @Mapping(source = "id" ,target = "id" ),
            @Mapping(source = "createTime" ,target = "createTime" ),
            @Mapping(source = "name" ,target = "name" ),
            @Mapping(source = "remark" ,target = "remark" ),
            @Mapping(source = "dataScope" ,target = "dataScope" ),
            @Mapping(source = "level" ,target = "level" ),
    })
    RolePO RoleDTOToRolePO(RoleDTO roleDTO);
}